package pers.qianyu.module.image.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pers.qianyu.module.core.comm.HttpResult;
import pers.qianyu.module.core.domain.image.vo.OssTokenVO;
import pers.qianyu.module.image.provider.IOssProvider;
import pers.qianyu.module.logging.annotation.ControllerLog;
import pers.qianyu.module.logging.enums.BusinessType;

/**
 * @author mizzle rain
 * @date 2021-04-27 15:49
 */
@Api(tags = "对象存储相关接口")
@RequestMapping("/image-serv")
@RestController
public class OssController {
    @Autowired
    private IOssProvider iOssProvider;

    @ApiOperation("获取阿里云OSS临时上传token")
    @ControllerLog(businessType = BusinessType.UPLOAD)
    @GetMapping("/file/token")
    public HttpResult<OssTokenVO> getOssToken() {
        OssTokenVO ossTokenVO = iOssProvider.getDirectToken();
        return HttpResult.okWithData(ossTokenVO);
    }
}
